<style>
.page-tab-content{background-color:transparent!important;}
.news-package-one{width:100px;height: 400px;float:left;padding-top: 30px;padding-left: 100px;}
.news-package-two{width:500px;float:left}
.news-package-two ul li{padding-left: 100px;padding-top: 20px;}
.size-com-font{padding-left: 120px;margin-top:20px;display:block;}

</style>
<div>
<form  class="layui-form" >
	<input type="hidden" name="ids_str" value="{$ids_str}">
	<input type="hidden" name="is_new_package"  value="" id="is_pack">

<div class="news-package-one">
	<label><input type="checkbox"  class="okpack"  lay-ignore  >生成新包</label>
</div>
<div class="news-package-two">
	 <span class="size-com-font">加入大包</span>
	<ul>
		{volist name="data" id="v"}
		<li><label><input type="checkbox" name="package_num"  class="mimo-tab" lay-ignore value="{$v.package_num}">大包号：{$v.package_num}</label>
		</li>
		{/volist}
	</ul>
</div>

<div class="pop-bottom-bar">
	<button type="submit" class="layui-btn" lay-submit  lay-filter="formSubmit1">确定</button>
	<a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
</div>
</form>
</div>
{include file="system@block/layui" /}

<script type="text/javascript">
	layui.use(['jquery', 'layer', 'form'], function() {
		var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;

		//监听提交
		form.on('submit(formSubmit1)', function(data){


			var myMsg =layer.load(1, {
				shade: [0.1,'#fff'] //0.1透明度的白色背景
			});

			//预防重复提交
			var DISABLED='layui-btn-disabled';
			$(':button').addClass(DISABLED);
			$(':button').attr('disabled','disabled');
			setTimeout(function() {
				$(":button").removeClass(DISABLED);
				$(":button").removeAttr('disabled');
			}, 4000);//4秒后才能点击

			if($(".okpack").prop('checked')){
				data.field.is_new_package=1;
			}else{
				data.field.is_new_package=0;
			}
			var arr = new Array();
			$("input:checkbox[name='package_num']:checked").each(function(i){
				arr[i] = $(this).val();
			});
			data.field.package_num = arr.join(",");//将数组合并成字符串
			$.post("{:url('creatPackage')}", {action:'ajaxCreatePackage',data:data.field}, function (res) {
				layer.close(myMsg);
				if (res.code == 1) {
					$(':button').addClass(DISABLED);
					$(':button').attr('disabled','disabled');
					layer.msg(res.msg, {time: 1800, icon: 1}, function () {
						var index = parent.layer.getFrameIndex(window.name);
					 	parent.layer.close(index);
						parent.reloadTable();
					});
				} else {
					layer.msg(res.msg, {time: 1800, icon: 2});
				}
			}, 'json');

			return false;
		});

	});
</script>